<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
$this->title = '管理员列表';
$this->params['breadcrumbs'][]='>';
$this->params['breadcrumbs'][] = ['label' => '管理员管理', 'url' => ['/admin/manage/managers']];
$this->params['breadcrumbs'][]='>';
$this->params['breadcrumbs'][] = $this->title;
$adminuser=Yii::$app->request->get('adminuser');
$startTime=Yii::$app->request->get('startTime');
$endTime=Yii::$app->request->get('endTime');
$css=<<<css
.form-group{float: left;margin:0 10px 10px 0;}
.form-group select{height: 30px;}
.post-search{float: left;margin:10px 0px;}
.common-ui{height: 40px;line-height: 40px;background:#169dd9;width: 100%;color:#fff;font-size: 14px;text-indent: 12px;display: block;float: left;margin-bottom: 10px;font-weight:normal;}
css;
$this->registerCss($css);
?>
<!-- main container -->
      
        <div class="container-fluid">
            <div id="pad-wrapper" class="users-list">
                <div class="row-fluid header">
                    <div class="span10 pull-right">
                        <a href="<?php echo yii\helpers\Url::to(['manage/reg']); ?>" class="btn-flat success pull-right">
                            <span>&#43;</span>
                            添加新管理员
                        </a>
                    </div>
                </div>
                <h3 class="common-ui" >查询</h3>
                <div class="comment-search" style="display: block;">
                    <div class="post-search">
                        <?php
                        $action=Url::to(['manage/managers']);
                        $form = ActiveForm::begin([
                            'action' => $action,
                            'method' => 'get',
                            'options'=>["class"=>"form-inline"],
                        ]);
                        ?>
                        <div class="form-group">
                            <?php echo Html::label('管理员账号:　', null). Html::textInput('adminuser',$adminuser,['placeholder' => '请输入管理员账号']); ?>
                        </div>
                        <div class="form-group">
                            <?php echo Html::label('创建时间:　', null). Html::textInput('startTime',$startTime,['placeholder' => '请选择开始时间','id'=>'text1']).' '.Html::textInput('endTime',$endTime,['placeholder' => '请选择结束时间','id'=>'text2']); ?>
                        </div>
                        <div class="form-group">
                            <?php echo Html::submitButton('查询', ['class' => 'btn btn-primary']); ?>
                            <?php echo Html::a('重置',Url::to(['manage/managers']), ['class' => 'btn btn-default']);?>
                        </div>
                        <?php ActiveForm::end(); ?>
                    </div>
                </div>

                <h3 class="common-ui" ><?php echo $this->title;?></h3>
                <!-- Users table -->
                <div class="row-fluid table">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th class="span2">
                                    管理员ID
                                </th>
                                <th class="span2">
                                    <span class="line"></span>管理员账号
                                </th>
                                <th class="span2">
                                    <span class="line"></span>管理员邮箱
                                </th>
                                <th class="span3">
                                    <span class="line"></span>最后登录时间
                                </th>
                                <th class="span3">
                                    <span class="line"></span>最后登录IP
                                </th>
                                <th class="span2">
                                    <span class="line"></span>添加时间
                                </th>
                                <th class="span2">
                                    <span class="line"></span>操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php foreach($managers as $manager): ?>
                        <!-- row -->
                        <tr>
                            <td>
                                <?php echo $manager->adminid; ?>
                            </td>
                            <td>
                                <?php echo $manager->adminuser; ?>
                            </td>
                            <td>
                                <?php echo $manager->adminemail; ?>
                            </td>
                            <td>
                                <?php echo date('Y-m-d H:i:s', $manager->logintime); ?>
                            </td>
                            <td>
                                <?php echo long2ip($manager->loginip); ?>
                            </td>
                            <td>
                                <?php echo date("Y-m-d H:i:s", $manager->createtime); ?>
                            </td>
                            <td class="align-right">
                            <?php if ($manager->adminid != 1): ?>
                            <a href="<?php echo Url::to(['manage/del', 'adminid' => $manager->adminid]) ?>">注销</a>
                            <a href="<?php echo Url::to(['manage/assign', 'adminid' => $manager->adminid]) ?>">授权</a>
                            <?php endif; ?>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                       </tbody>
                    </table>
                    <?php
                        if (Yii::$app->session->hasFlash('info')) {
                            echo Yii::$app->session->getFlash('info');
                        }
                    ?>
                </div>
                <div class="pagination pull-right">
                    <?php echo yii\widgets\LinkPager::widget(['pagination' => $pager, 'prevPageLabel' => '&#8249;', 'nextPageLabel' => '&#8250;']); ?>
                </div>
                <div class="pagination pull-right">
                    <span>共<?php echo $total;?>条</span>
                    <div class="pagination ui-select" style="margin-right: 10px;">
                        <select name="per-page">
                            <option value="10">10条/页</option>
                            <option value="20">20条/页</option>
                            <option value="50">50条/页</option>
                            <option value="100">100条/页</option>
                            <option value="200">200条/页</option>
                            <option value="300">300条/页</option>
                            <option value="500">500条/页</option>
                        </select>
                    </div>
                </div>
                <!-- end users table -->
            </div>
        </div>
    <!-- end main container -->
<?php
$jspage=<<<JS
$(":input[name=per-page]").val($pagesize);
$(":input[name=per-page]").change(function() {
    var size=$(':input[name=per-page]').find('option:selected').val();
    window.location.href='$pageurl'+size;
});
JS;
$this->registerJs($jspage);
$this->registerJsFile('/web/laydate/laydate.js');
$jstime=<<<JS
    laydate.render({
        elem: '#text1', //指定元素
        type:'datetime',
    });
    laydate.render({
        elem: '#text2', //指定元素
        type:'datetime',
    });
JS;
$this->registerJs($jstime);
?>
